import { Login } from '@/api/interface'
import { cwl, PORT1 } from '@/api/config/servicePort'
import authMenuList from '@/assets/json/authMenuList.json'
import authButtonList from '@/assets/json/authButtonList.json'
import http from '@/api'
import list from '@/assets/json/list.json'

/**
 * 登录模块
 */
// 用户登录
export const loginApi = (params: Login.ReqLoginForm) => {
  return http.post<Login.ResLogin>(PORT1 + `/login`, params, { loading: false }) // 正常 post json 请求  ==>  application/json
  // return http.post<Login.ResLogin>(PORT1 + `/login`, params, { loading: false }); // 控制当前请求不显示 loading
  // return http.post<Login.ResLogin>(PORT1 + `/login`, {}, { params }); // post 请求携带 query 参数  ==>  ?username=admin&password=123456
  // return http.post<Login.ResLogin>(PORT1 + `/login`, qs.stringify(params)); // post 请求携带表单参数  ==>  application/x-www-form-urlencoded
  // return http.get<Login.ResLogin>(PORT1 + `/login?${qs.stringify(params, { arrayFormat: "repeat" })}`); // get 请求可以携带数组等复杂参数
}

// 获取菜单列表
export const getAuthMenuListApi = () => {
  // return http.get<Menu.MenuOptions[]>(PORT1 + `/menu/list`, {}, { loading: false });
  // 如果想让菜单变为本地数据，注释上一行代码，并引入本地 authMenuList.json 数据
  // return authMenuList
  return list
}

// 获取按钮权限
export const getAuthButtonListApi = () => {
  // return http.get<Login.ResAuthButtons>(PORT1 + `/auth/buttons`, {}, { loading: false });
  // 如果想让按钮权限变为本地数据，注释上一行代码，并引入本地 authButtonList.json 数据
  return authButtonList
}

// 用户退出登录
export const logoutApi = () => {
  return http.post(PORT1 + `/logout`)
}

export const temData = (params: any) => {
  return http.post(cwl + '/api/tbSysLog/page/like', params)
  /*return new Promise(resolve =>
    resolve({
      code: 200,
      msg: null,
      data: {
        total: 22802,
        list: [
          {
            id: 26455,
            title: '车辆离场显示',
            content: '浙A3Z583 车辆已离场',
            createTime: '2024-09-29 09:41:27'
          },
          {
            id: 26454,
            title: '车辆离场显示',
            content: '浙A02B95 车辆已离场',
            createTime: '2024-09-29 09:40:09'
          },
          {
            id: 26453,
            title: '海康威视显示记录',
            content: '皖F88458称重17.82吨,过磅完成',
            createTime: '2024-09-29 09:39:49'
          },
          {
            id: 26452,
            title: '车辆离场显示',
            content: '浙A70A83 车辆已离场',
            createTime: '2024-09-29 09:39:39'
          },
          {
            id: 26451,
            title: '车辆离场显示',
            content: '浙A37E56 车辆已离场',
            createTime: '2024-09-29 09:39:27'
          },
          {
            id: 26450,
            title: '车辆离场显示',
            content: '浙FF5981 车辆已离场',
            createTime: '2024-09-29 09:39:09'
          },
          {
            id: 26449,
            title: '车辆离场显示',
            content: '浙A88C27 车辆已离场',
            createTime: '2024-09-29 09:38:38'
          },
          {
            id: 26448,
            title: '车辆离场显示',
            content: '浙A07157D 车辆已离场',
            createTime: '2024-09-29 09:38:17'
          },
          {
            id: 26447,
            title: '海康威视显示记录',
            content: '浙A02B95,未匹配到运输单!',
            createTime: '2024-09-29 09:37:46'
          },
          {
            id: 26446,
            title: '海康威视显示记录',
            content: '浙A02B95称重18.64吨,过磅完成',
            createTime: '2024-09-29 09:37:10'
          }
        ],
        pageNum: 1,
        pageSize: 10,
        size: 10,
        startRow: 1,
        endRow: 10,
        pages: 2281,
        prePage: 0,
        nextPage: 2,
        isFirstPage: true,
        isLastPage: false,
        hasPreviousPage: false,
        hasNextPage: true,
        navigatePages: 8,
        navigatepageNums: [1, 2, 3, 4, 5, 6, 7, 8],
        navigateFirstPage: 1,
        navigateLastPage: 8
      },
      success: true
    })
  )*/
}
export const getVehicelList = (params, loading: boolean = false) => {
  return http.post(cwl + `/api/tbBaseVehicle/like`, params, { loading })
}
